function bubbleSort(array) {
  let result = [];
  for (let i = 0; i < array.length; i++) {
    for (let j = 0; j < array.length - i; j++) {
      const A = array[j];
      const B = array[j + 1];
      // 交换位置
      if(A > B) {
        array[j] = B;
        array[j+1] = A;
      }
    }
  }
  console.log(array)
}
bubbleSort([3, 6, 2, 4, 1])